<?php
include('./library/connection.php');
$username = $_REQUEST['sl-username'];
$password = $_REQUEST['sl-password'];

$select = "select * from users where username='$username' and password = '$password'";
$result = $mysqli->query($select);
$mysqli->close();
if ($result->num_rows) {
    $row = $result->fetch_assoc();
    setcookie('username', $row['username'], time() + 3600 * 24, '/');
    setcookie('isLogined', 'true', time() + 3600 * 24, '/');
    echo "<script>alert('登录成功')</script>";
    echo "<script>location.href='../src/html/index.html'</script>";
} else {
    echo "<script>alert('用户名或密码错误')</script>";
    echo "<script>location.href='../src/html/login.html'</script>";
}
